﻿using MN.Framework.Common;
using MN.Framework.MetaData;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TZ.Common
{

    [EntityHeader("پذیرش بیماران")]
    [AssociatedWith(typeof(Person), "PersonID", MN.Framework.MetaData.AssociationType.OneToMany)]
    public partial class Reception : BaseEntity
    {
        public decimal Remaining
        {
            get
            {
                return ServiceCost.Value - Payment.Value;
            }
        }


        public override void GetColumns(List<ColumnInfo> columns)
        {
            columns.Add(new NumericColumnInfo("ID", "شناسه", true));
            columns.Add(new ReferenceColumnInfo("PersonID", "بیمار"));
            columns.Add(new PersianDateColumnInfo("DateTime", "تاریخ مراجعه"));
            columns.Add(new TextColumnInfo("ServiceDesc", "شرح خدمات", ColumnSize.XLarg));
            columns.Add(new NumericColumnInfo("ServiceCost", "هزینه خدمات", NumericType.FloatingPoint, typeof(decimal)));
            columns.Add(new NumericColumnInfo("Discount", "تخفیف", NumericType.FloatingPoint, typeof(decimal)));
            columns.Add(new NumericColumnInfo("Consumables", "هزینه مواد مصرفی", NumericType.FloatingPoint, typeof(decimal)));
            columns.Add(new NumericColumnInfo("Payment", "مبلغ پرداختی", NumericType.FloatingPoint, typeof(decimal)));
            columns.Add(new NumericColumnInfo("Remaining", "مانده",NumericType.FloatingPoint,typeof(decimal), true));
        }
        public override void RegisterValidationRules()
        {
                base.RegisterValidationRules();
                AddRule("Discount", new LogicalValidationRule(LogicalOperator.LessThan, "ServiceCost"));
        }
    }
}
